package com.kaifamiao.www.Thread.do0926;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class TestMC {
    public static void main(String[] args) {

        MyCallable call = new MyCallable();
        //获取线程执行完毕之后的结果，也可以作为参数传递给Thread对象
        FutureTask<Integer> task = new FutureTask<Integer>(call);
        //分配一个指定目标的新的线程对象
        Thread thread = new Thread(task);
        thread.start();
        try {
            int a = task.get();
            System.out.println(a);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}
